package cn.tedu.jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo5 {
    public static void main(String[] args) {
        try(Connection connection=DBUtil.getConnextion("tedu")) {
           Statement statement =connection.createStatement();
           String sql="select username,password,nickname,age from userinfo";
           ResultSet result=statement.executeQuery(sql);
            System.out.println("用户名    密码    昵称    年龄");
           while (result.next()){
               String username=result.getString("username");
               String password=result.getString("password");
               String nickname=result.getString("nickname");
               int age=result.getInt("age");
               System.out.println(username+"  "+password+"  "+nickname+"  "+age);
           }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
